package com.xncoding.aop.controller;

import com.xncoding.aop.annotation.RedisCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.xncoding.aop.annotation.UserAccess;

import javax.ws.rs.core.Response;


/**
 * Description:
 */
@RestController
public class UserController {
    @Autowired
    ConfigurableEnvironment environment;

    @RequestMapping("/first")
    public Object first() {
        return "first controller";
    }

    @RequestMapping("/doError")
    public Object error() {
        return 1 / 0;
    }

	@RequestMapping("/second")
    @UserAccess(desc = "${brother-rooster.skill}")
    public Object second() {

        System.out.println(environment.resolvePlaceholders("${brother-rooster.skill}"));
        System.out.println(environment.resolvePlaceholders("abcd"));
        return "second controller";
    }

    @RequestMapping("/achieve")
    public Response achieve(){
        System.out.println("方法执行-----------");
        return Response.ok("122").build();
    }
    @RedisCache(type = Response.class)
    @RequestMapping("/sendEmail")
    public Response sendEmailToAuthor(String content){
        System.out.println("测试执行次数");
        return Response.ok("000000").build();
    }



}
